package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;

import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_revoke_order_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.RevokeOrderInfoMapper")
public class RevokeOrderInfo extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 交易中心主键
     */
    @TableField(value = "center_id")
    private Long centerId;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 受益人签署的撤销保函声明文件 路径
     */
    @TableField(value = "revoke_declare_file")
    private String revokeDeclareFile;

    /**
     * 受益人签署的撤销保函声明文件hash码,sha256算法
     */
    @TableField(value = "revoke_declare_hash")
    private String revokeDeclareHash;

    /**
     * 撤销订单号|批次号 唯一
     */
    @TableField(value = "revoke_no")
    private String revokeNo;

    /**
     * 项目编码
     */
    @TableField(value = "project_code")
    private String projectCode;

    /**
     * 合同/工程/标段编码
     */
    @TableField(value = "section_code")
    private String sectionCode;

    /**
     * 项目名称
     */
    @TableField(value = "project_name")
    private String projectName;

    /**
     * 合同/工程/标段名称
     */
    @TableField(value = "section_name")
    private String sectionName;

    /**
     * 招标企业名称
     */
    @TableField(value = "tenderer")
    private String tenderer;

    /**
     * 请求中的备注说明
     */
    @TableField(value = "note")
    private String note;

    /**
     * 0未处理 1已处理 2处理异常
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 要撤销的保函数据,(json格式化后的字符)
     */
    @TableField(value = "revoke_guarantee_data")
    private String revokeGuaranteeData;

    /**
     * 退款账户所属银行名称
     */
    @TableField(value = "bank_name")
    private String bankName;

    /**
     * 退款账户名称
     */
    @TableField(value = "account_name")
    private String accountName;

    /**
     * 退款账户账号
     */
    @TableField(value = "bank_card_num")
    private String bankCardNum;

    /**
     * 退款账户所属开户行
     */
    @TableField(value = "open_bank_name")
    private String openBankName;

    /**
     * 保函撤销费用
     */
    @TableField(value = "back_premium")
    private Long backPremium;

    public RevokeOrderInfoVo buildVo() {
        return new RevokeOrderInfoVo(id, centerId, orgId, revokeDeclareFile, revokeDeclareHash, revokeNo, projectCode, sectionCode, projectName, sectionName, tenderer, note, status, gmtCreate, gmtModified, userCreate, userModified, remark, revokeGuaranteeData, bankName, accountName, bankCardNum, openBankName, backPremium);
    }

    public static RevokeOrderInfo of(RevokeOrderInfoVo vo) {
        return new RevokeOrderInfo(vo.getId(), vo.getCenterId(), vo.getOrgId(), vo.getRevokeDeclareFile(), vo.getRevokeDeclareHash(), vo.getRevokeNo(), vo.getProjectCode(), vo.getSectionCode(), vo.getProjectName(), vo.getSectionName(), vo.getTenderer(), vo.getNote(), vo.getStatus(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getRemark(), vo.getRevokeGuaranteeData(), vo.getBankName(), vo.getAccountName(), vo.getBankCardNum(), vo.getOpenBankName(), vo.getBackPremium());
    }
}
